package TeachLesson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;

@WebServlet(name = "addStudyUnitServlet")
public class addStudyUnitServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //添加学习单元
        try {
            String dirName=request.getParameter("dirName");
            String workerNo=request.getParameter("workerNo");
            String courseNo=request.getParameter("courseNo");
           // File pFdir1=new File("f:\\JWGLXT\\StoreResoures",workerNo);
           /* File pFdir2=new File("StoreResoures\\"+workerNo,workerNo);
            if(!pFdir2.isDirectory()){  //如果目录不存在,创建之
               pFdir2.mkdir();
            }*/
            File fdir=new File("F:\\JWGLXT\\web\\StoreResoures\\"+workerNo+"\\"+courseNo+"\\"+dirName);
            if(!fdir.isDirectory()){//如果目录不存在
                fdir.mkdirs();
            }
            response.sendRedirect("/Teachers/unitStudy.jsp");
        }catch (Exception e){
            e.printStackTrace();
            response.getWriter().println("添加失败");
        }
    }
}
